
package com.yuan.view;

import com.yuan.graduate.R;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

/**
 * 公共头部
 * 
 * @author YUAN
 */
public class Commhead extends RelativeLayout {
    private Context mContext = null;
    private TextView back, title;
    private View title_line;

    public Commhead(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
        initView();
    }

    private void initView() {
        // TODO Auto-generated method stub
        LayoutInflater.from(mContext).inflate(R.layout.pref_header, this);
        back = (TextView) findViewById(R.id.back);
        title = (TextView) findViewById(R.id.title);
        title_line = (View) findViewById(R.id.title_line);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                ((Activity) mContext).finish();

            }
        });
    }

    public void settitleString(String str) {
        title.setText(str);
    }

    public void hintRightIcon() {
        back.setVisibility(View.INVISIBLE);
        title_line.setVisibility(View.INVISIBLE);
    }

    public void setLeftIcon(int rdid) {
        back.setBackgroundResource(rdid);
    }

    public void setLeftOnClickListener(View.OnClickListener mOnClickListener) {
        back.setOnClickListener(mOnClickListener);
    }
}
